package model;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.annotation.SuppressLint;
import android.os.Parcel;
import android.os.Parcelable;

@SuppressLint("SimpleDateFormat")
public class Conference implements Serializable, Parcelable {

	private static final long serialVersionUID = 1L;

	private int id;
	private String name;
	private String city;
	private Date date;
	private String description;
	private String speaker;
	private String bio;
	private double lat;
	private double lon;

	public Conference() {
		id = 0;
		name = new String();
		city = new String();
		date = new Date();
		description = new String();
		speaker = new String();
		bio = new String();
		lat = 0;
		lon = 0;
	}

	public Conference (Parcel in) throws ParseException
	   {
		id = in.readInt();
		name = in.readString();
		city = in.readString();
		date = new SimpleDateFormat("MMMM d, yyyy",
				Locale.ENGLISH).parse(in.readString());
		description = in.readString();
		speaker = in.readString();
		bio = in.readString();
		lat = in.readDouble();
		lon = in.readDouble();
	   }
	
	public Conference(int id, String name, String city, Date date,
			String description, String speaker, String bio, double lat,
			double lon) {
		this.id = id;
		this.name = name;
		this.city = city;
		this.date = date;
		this.description = description;
		this.speaker = speaker;
		this.bio = bio;
		this.lat = lat;
		this.lon = lon;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getSpeaker() {
		return speaker;
	}

	public void setSpeaker(String speaker) {
		this.speaker = speaker;
	}

	public String getBio() {
		return bio;
	}

	public void setBio(String bio) {
		this.bio = bio;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLon() {
		return lon;
	}

	public void setLon(double lon) {
		this.lon = lon;
	}

	public String toString() {
		return id + " " + name + " " + city + " " + date.toString() + " "
				+ description + " " + speaker + " " + bio + " " + lat + " "
				+ lon;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	public static final Parcelable.Creator<Conference> CREATOR = new Parcelable.Creator<Conference>() {
		public Conference createFromParcel(Parcel in) {
			try {
				return new Conference(in);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			return null;
		}

		public Conference[] newArray(int size) {
			return new Conference[size];
		}
	};

	@Override
	public void writeToParcel(Parcel arg0, int arg1) {
		// TODO Auto-generated method stub
		arg0.writeInt(id);
		arg0.writeString(name);
		arg0.writeString(city);
		arg0.writeString(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
				.format(date));
		arg0.writeString(description);
		arg0.writeString(speaker);
		arg0.writeString(bio);
		arg0.writeDouble(lat);
		arg0.writeDouble(lon);
	}
}
